package com.itheima.module.web.vo;

/**
 * @author huyoufu <https://github.com/huyoufu>
 * @TIME 2021-09-03 04:03
 * @description web返回状态码 定义
 */
public class Result {
    private String code;
    private String desc;
    private Object data;

    public static  Result successOf() {
        return new Result(ResultCodeEnum.SUCCESS,null);
    }
    public static  Result successOf(Object data) {
        return new Result(ResultCodeEnum.SUCCESS,data);
    }
    public static  Result failOf(ResultCodeEnum resultCodeEnum) {
        return new Result(resultCodeEnum,null);
    }
    public static  Result failOf(ResultCodeEnum resultCodeEnum,Object data) {
        return new Result(resultCodeEnum,data);
    }
    private Result(ResultCodeEnum resultCodeEnum,Object data){
        this.code=resultCodeEnum.getCode();
        this.desc=resultCodeEnum.getDesc();
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
